package com.haopt.clock.service.impl;

import com.haopt.clock.dao.TRecordMapper;
import com.haopt.clock.dto.ResultDTO;
import com.haopt.clock.entity.TRecord;
import com.haopt.clock.service.RecordService;
import com.haopt.clock.vo.ResRecordDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Service
public class RecordServiceImpl implements RecordService {
    @Autowired
    private TRecordMapper recordMapper;
    @Override
    public ResultDTO<List<ResRecordDetailVO>> list(String userId) {
        TRecord searchBean = new TRecord();
        searchBean.setUserId(userId);
        List<TRecord> resList = recordMapper.select(searchBean);
        List<ResRecordDetailVO> list = new ArrayList<>();
        if(CollectionUtils.isEmpty(resList)){
            return ResultDTO.okOf(list);
        }
        resList.forEach(bean0->{
            ResRecordDetailVO result = new ResRecordDetailVO();
            result.setDate(bean0.getRecordTime());
            result.setInfo("打卡");
            list.add(result);
        });
        return ResultDTO.okOf(list);
    }
}
